home *** CD-ROM | disk | FTP | other *** search
- # include "nrs.h"
- #define void_result 0
- #ifndef void_res
- #define void_res int
- #endif/*void_res*/
-
- # ifndef lint
- static char RCSid[]="@(#)$Header: output.c,v 3.6 88/09/08 17:39:37 pb Exp $";
- # endif
- /***********************************************************************\
- * *
- * This module does all the output formatting. *
- * Currently it supports *
- * york directory format *
- * /etc/x25hosts format (UBC X25 code) *
- * mmdf domain table format *
- * *
- * Fri Jun 28 17:08:17 1985 Julian Onions <jpo@uk.ac.nott.cs> *
- * *
- * MMDF output routines rewritten, york2.1 rewritten, york 2.2 added, *
- * text added, VMS added, sendmail added. *
- * *
- * Piete Brooks <pb@uk.ac.cam.cl> *
- * *
- * Reading Sendmail format added *
- * *
- * Adrian Pell <A.R.Pell@uk.ac.reading> *
- * *
- * Copyright 1986, Piete Brooks, Julian Onions & Adrian Pell *
- * pb@cl.cam.ac.uk, jpo@hcig.nott.ac.uk, Adrian.R.Pell@reading.ac.uk *
- * *
- * This program may be copied as long as you don't remove this notice, *
- * try to make any money off of it, or pretend that you wrote it. *
- * *
- * S.E.R.C. Prime textual format added *
- * Ian Pallfreeman <ian@uk.ac.umist> *
- * *
- * Edinburgh Text format added *
- * Scott Larnach <scott@uk.ac.ed> *
- * *
- \***********************************************************************/
-
- /* ARGSUSED */
- /* This is the default format -- i.e. crash out ! */
- void_res
- noformat(longform, shortform, ap, m3p)
- Mod2 *longform;
- Mod2 *shortform;
- Atomic *ap;
- Mod3 *m3p;
- {
- fatal1("No %s output format specified\n",
- (m3p) ? "reverse" : "forward");
- /* NOTREACHED */
- return void_result; /* keep gcc -Wall happy */
- }
-
- /* Given a name (from application relay) ensure it's of the right form.
- *
- * Caching: Quickie -- remember last conversion.
- * This will solve double short/long lookup if 1 AP, and also
- * will work wonders for a goup of machines using the same relay ...
- * Currently does 25 lookups and 92 caches -- perfect is 21 and 96 ...
- *
- * pb@cam.cl
- */
- static_f char *
- longshort_name(name)
- char *name;
- { Mod2 *m2, *findm2rec();
- static char *from=NULL, *to=NULL;
-
- if (from && to && !strcmp(name, from))
- { vprintf2(2, "[Cached %s -> %s]\n", from, to);
- return to;
- }
- if ( (m2=findm2rec(name)) && /* Name exists */
- (m2->ls == longshort || /* Already there .. */
- (m2->ls == SHORT && longshort != LONG) ||
- (m2->ls_disp && /* or other form exists */
- (m2=getm2rec(m2->ls_disp))))) /* and can be found */
- { if (from) free(from);
- if (to) free(to);
- from=strdup(name);
- to=strdup(m2->name);
- vprintf2(2, "[Looked up %s -> %s]\n", name, m2->name);
- return (to) ? to : m2->name;
- }
- vprintf1(2, "[Missed %s]\n", name);
- return name;
- }
-
- #ifdef FLIP
- #define noflip(x) x
- char *flip(str)
- char *str;
- {
- static char flipbuf[MAXNAMELEN];
- register char *dp, *flipp;
- int i;
-
- flipp = flipbuf;
- for(i = 1, dp = str + strlen(str) - 1; dp > str; dp --)
- {
- if( *dp == '.')
- {
- VOID strncpy(flipp, dp+1, i);
- flipp += i - 1;
- *flipp++ = '.';
- i = 1;
- }
- else i++;
- }
- VOID strncpy(flipp, dp, i);
- *(flipp + i) = '\0';
- return flipbuf;
- }
- # endif FLIP
-
- # ifdef MULT_OUTPUT_FILES
- File_list *findfile(tbl, s, short_name)
- File_list *tbl;
- int short_name;
- char *s;
- {
- if (short_name)
- for(; tbl->dname != 0; tbl++)
- { int len = strlen(tbl->dname);
- if( tbl->net )
- continue;
- if( lexequ(s, tbl->dname, len) && len < strlen(s))
- return tbl;
- }
- else for(; tbl->ldname != 0; tbl++)
- { int len = strlen(tbl->ldname);
- if( tbl->net )
- continue;
- if( lexequ(s, tbl->ldname, len) && len < strlen(s))
- return tbl;
- }
- return NULL;
- }
-
- File_list *findnet(tbl, n)
- File_list *tbl;
- int n;
- {
- for(; tbl->dname != 0; tbl++)
- if( tbl->net == n)
- return tbl;
- return NULL;
- }
- # endif MULT_OUTPUT_FILES
-
- # ifdef F_YORK
- void_res
- yorkformat(longform, shortform, ap, m3p) /* york directory format */
- Mod2 *longform;
- Mod2 *shortform;
- Atomic *ap;
- Mod3 *m3p;
- {
- static headed = 0;
-
- /* The name I'm actually interested in */
- char *name = longform->name;
- char *abbrev = (shortform) ? shortform->name : name;
- /* Does it have the default service name ? */
- char default_name = 0;
- /* This is the service string I EXPECT */
- int context = (m3p) ? m3p->m3_context : ap->context;
- char *expected_ybts = vlookup(context, def_ybstring);
- /* This is the DTE to use:
- * EITHER ap->dte for forward
- * OR part of text for reverse
- */
- char *dte = (m3p) ? m3p->m3_dte : ap->dte;
- char *ybts= (m3p) ? m3p->m3_ybts : ap->ybts;
- /* Should there be any YBTS string ? */
- char no_ybts = (ybts && *ybts) ? 0 : 1;
- int network = (m3p) ? m3p->m3_network : ap->network;
- int yblen;
- /* This is a LOCAL COPY of the TS string */
- char ybstring[256];
-
- if( headed == 0 && commentfile)
- {
- addcomments(stdout, (m3p) ?
- "york format reverse NRS table" :
- "york format NRS table",
- "Lookup Table");
- headed++;
- }
-
- if (m3p && ! dte)
- { dte=nullstring;
- if (context == MAIL_NIFTP) return void_result;
- }
-
- /* <isunix>:<network>:<services>:<name>[|abbrev]:<addr>:<comment> */
- VOID strcpy(ybstring, ybts);
- if (expected_ybts)
- { /* Identical ? */
- if ( strcmp(ybstring, expected_ybts ) == 0)
- { default_name++;
- no_ybts++;
- }
- /* Null ybts expected */
- else if (*expected_ybts == '\0')
- default_name++;
- /* trailing sub-string ? */
- else if (yblen = strlen(ybstring))
- { char *end = ybstring + yblen - strlen(expected_ybts);
-
- /* NB: If YBTS is of the form
- * 1234/FTP.MAIL
- * then DONT compress it, as we would generate
- * 1234.FTP.MAIL
- * from :m:name:000012345678/1234:
- */
- if (end > ybstring &&
- strcmp(end, expected_ybts) == 0 &&
- end[-1] == '.')
- { default_name++;
- end[-1] = '\0';
- }
- }
- }
- /* If no ybts, but none expected, then use explicit ! */
- else if ( expected_ybts && *expected_ybts == '\0')
- default_name++;
-
- { char * net = vlookup(network, netnames);
- char *cont = (context == DESC) ? nullstring :
- vlookup(context, default_name ? imp_services:
- exp_services);
- if (!net)
- { warn2(1, "%10s: net 0x%02x unknown",
- name, network);
- net = "??";
- }
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown",
- name, context);
- cont = "??";
- }
- printf("0:%s:%s%s%s:%s", net,
- (m3p) ? "|" : "", cont, (m3p) ? "" : "|", name);
- }
-
- if (strcmp(name, abbrev))
- printf("|%s", abbrev);
- printf(":");
-
- /* Prefix with gateway if needed .... */
- if(network == PSS && pssgateway) printf("%s", pssgateway);
- if(network == JANET && janetgateway) printf("%s", janetgateway);
-
- /* The DTE .... */
- printf("%s", dte);
- /* Plus YBTS */
- if( ! no_ybts )
- { char * colon;
- while (colon = index(ybstring, ':')) *colon = COLON;
- printf("/%s", ybstring);
- }
- printf(":");
-
- /* The prefix which was stripped */
- printf(":");
-
- /* The extra values */
- if( !m3p && ap->n_relays > 0 )
- { int relay;
- char * cont = vlookup(ap->context, exp_services);
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown",
- name, ap->context);
- cont = "?";
- }
- printf("ar%s=", cont);
- for (relay=0; relay < ap->n_relays; relay++)
- { char * colon = ap->ar[relay];
- while (colon = index(colon, ':')) *colon++ = COLON;
- printf("%s%s", (relay==0) ? "" : ",", ap->ar[relay]);
- }
- }
- printf(":");
-
- if( !m3p && ap->n_descs > 0 )
- { int desc;
- for (desc=0; desc < ap->n_descs; desc++)
- printf("%s%s", (desc==0) ? "" : "|", ap->desc[desc]);
- }
- /* The comment */
- printf("\n");
-
- if (m3p && ap && dte != ap->dte && ap->dte && strcmp(dte, ap->dte))
- warn3(1, "%-18s DTE is %-14s rather than %-14s",
- name, dte, ap->dte);
- return void_result;
- }
-
- # endif F_YORK
-
- # ifdef F_X25HOSTS
- /* ARGSUSED */
- void_res
- x25hostsformat(longform, shortform, ap, m3p) /* etc/x25hosts format */
- Mod2 *longform;
- Mod2 *shortform;
- Atomic *ap;
- Mod3 *m3p;
- {
- static headed = 0;
-
- if (!ap)
- { warn0(1, "X25HOSTS passed reverse object");
- return void_result;
- }
-
- if(ap->n_relays > 0 || (ap->ybts && *ap->ybts) )
- return void_result;
-
- if ( ! shortform)
- shortform = longform;
- if( headed == 0 && commentfile)
- {
- addcomments(stdout, "x25hosts NRS tables", "Lookup Table");
- headed++;
- }
-
- printf("%-14s ", ap->dte);
- if(stripoff && lexequ(stripoff, shortform->name, strlen(stripoff)) )
- printf("%-19s ", shortform->name + strlen(stripoff));
- printf("%-19s ", shortform->name);
- if( ! lexequ(shortform->name, longform->name, strlen(longform->name)))
- {
- if(stripoff && lexequ(stripoff, longform->name, strlen(stripoff)) )
- printf("%-19s ", longform->name + strlen(stripoff));
- printf(" %s", longform->name);
- }
- putchar('\n');
- return void_result;
- }
- # endif F_X25HOSTS
-
- # ifdef F_MMDF
- /* ARGSUSED */
- void_res
- mmdfformat(longform, shortform, ap, m3p) /* mmdf domain table format */
- Mod2 *longform;
- Mod2 *shortform;
- Atomic *ap;
- Mod3 *m3p;
- {
- File_list *filep;
- FILE *fp;
- char *flip();
- int i;
- char *name1, *name2, *dmn1;
-
- if (!ap)
- { warn0(1, "MMDF passed reverse object");
- return void_result;
- }
-
- if ( ! shortform)
- shortform = longform;
-
- if( longshort == LONG ) /* output in short = alias of long */
- name1 = longform->name, name2 = shortform->name;
- else name1 = shortform->name, name2 = longform->name;
-
- if((filep = findfile(fil_list, name1, longshort != LONG)) == NULL)
- { warn1(1, "can't find a place for %s", name1);
- return void_result;
- }
-
- if( longshort == LONG ) /* output in short = alias of long */
- dmn1 = filep->ldname;
- else dmn1 = filep->dname;
-
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- {
- addcomments(fp, filep->fname, "Domain Table");
- filep->flags |= USED;
- }
-
- fprintf(fp, "%s:", flip(name1 + strlen(dmn1)));
- fprintf(fp, "%s", flip(name1));
- if(! (filep->flags & LOCAL)) /* not a local domain */
- { if (relay_host) /* and we have a relay point*/
- fprintf(fp, " %s", relay_host);
- /* else dump the AR */
- else for( i = 0; i < ap->n_relays; i++)
- fprintf(fp, " %s", flip(longshort_name(ap->ar[i])));
- }
- putc('\n', fp);
- /* compare two forms - if there the same skip - take care to compare
- the two forms without dmns on. e.g. uk.ac.shtdmn.cs &&
- uk.ac.longishdmn.cs are the same if in longishdmn */
-
- if((filep = findfile(fil_list, name2, longshort == LONG)) == NULL)
- warn2(1, "can't find a place for other form of %s (%s)",
- name1, name2);
- else
- { char *dmn2;
- if( longshort != LONG ) /* output in short = alias of long */
- dmn2 = filep->ldname;
- else dmn2 = filep->dname;
-
- if( ! lexequ(name1 + strlen(dmn1), name2 + strlen(dmn2),
- strlen(longform->name) - strlen(filep->ldname)))
- { fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- {
- addcomments(fp, filep->fname, "Domain Table");
- filep->flags |= USED;
- }
- fprintf(fp, "%s:", flip(name2 + strlen(dmn2)));
- fprintf(fp, "%s", flip(name1));
- if (! (filep->flags & LOCAL)) /* not a local domain */
- { if (relay_host) /* and we have a relay point*/
- fprintf(fp, " %s", relay_host);
- /* else dump the AR */
- else for( i = 0; i < ap->n_relays; i++)
- fprintf(fp, " %s", flip(longshort_name(ap->ar[i])));
- }
- putc('\n', fp);
- }
- }
-
- /* It isn't local, then if App Relay or relay_host, no chan needed */
- if(! (filep->flags & LOCAL)) /* not a local domain */
- if (relay_host || ap->n_relays > 0) return void_result;
-
- if((filep = findnet(fil_list, ap->network)) == NULL)
- return void_result;
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- {
- addcomments(fp, filep->fname, "Channel Table");
- filep->flags |= USED;
- }
- fprintf( fp, "%s:", flip(name1));
- if( *filep->dname && lexequ(filep->dname, name1, i = strlen(filep->dname)))
- fprintf(fp, "%s\n", name1 + i );
- else fprintf(fp, "%s\n", name1);
-
- #ifdef MMDF_CHAN_BOTH_FORMS
- /* It has been reported that mmdf does not need chanel tables for both
- * the long & short, as only one should be generated by the domain
- * tables. However, some sites aren't very strict about that ...
- */
- if(lexequ(name1, name2, strlen(longform->name)) )
- return void_result;
-
- fprintf( fp, "%s:", flip(name2));
- if( *filep->dname && lexequ(filep->dname, name2, i = strlen(filep->dname)))
- fprintf(fp, "%s\n", name2 + i );
- else fprintf(fp, "%s\n", name2);
- #endif MMDF_CHAN_BOTH_FORMS
- return void_result;
- }
-
- void_res
- mmdfdomain(dp)
- Domain *dp;
- { static char name1[] = "-top.dmn-...";
- File_list *filep;
- FILE *fp;
- char *flip();
-
- if((filep = findfile(fil_list, name1, 1)) == NULL)
- { warn1(1, "can't find a place for %s", name1);
- return void_result;
- }
-
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- {
- addcomments(fp, filep->fname, "Top Domain Table");
- filep->flags |= USED;
- }
-
- fprintf(fp, "%s:", flip(dp->name));
- fprintf(fp, "%s\n", flip(longshort_name(dp->gateway)));
-
- return void_result;
- }
- # endif F_MMDF
-
- #ifdef F_TEXT
- void_res
- textformat(longname, shortname, ap, m3p)
- Mod2 *longname, *shortname;
- Atomic *ap;
- Mod3 *m3p;
- {
- if (m3p) printf("Calling address %s\n", m3p->m3_string);
- if (longshort == LONG || !shortname)
- printf("Standard name %s\n", longname->name);
- if (longshort != LONG && shortname)
- printf("Abbreviated name %s\n", shortname->name);
- if (!m3p) {
- if (ap->dte && *ap->dte)
- printf("DTE %s\n", ap->dte);
- if (ap->ybts && *ap->ybts)
- printf("YB String %s\n", ap->ybts);
- { int i;
- for (i=0; i< ap->n_relays; i++)
- printf("Application Relay %s\n", ap->ar[i]);
- for (i=0; i< ap->n_descs; i++)
- printf("Description %s\n", ap->desc[i]);
- }
- }
- else {
- if (m3p->m3_dte)
- printf("DTE %s\n", m3p->m3_dte);
- if (*(m3p->m3_ybts))
- printf("YB String %s\n", m3p->m3_ybts);
- { int i;
- for (i=0; i< ap->n_descs; i++)
- printf("Description %s\n", ap->desc[i]);
- }
- }
- printf("\n");
- return void_result;
- }
- #endif F_TEXT
-
- #ifdef F_VMS4
- #define max_name_len 32
- /* Thee is no way to represent an applicatio relay, so do not generate it */
- #define has_relay() (! m3p && ap->n_relays && !ignore_relay)
-
- char *
- vms4_quote(name)
- char *name;
- { static char buff[1024];
- if (!index(name, '-')) return name;
- VOID sprintf(buff, "\"%s\"", name);
- return buff;
- }
-
- /* ARGSUSED */
- void_res
- vms4_single(m2p, ap, m3p, skip)
- int skip;
- Mod2 *m2p;
- Atomic *ap;
- Mod3 *m3p;
- { char *quote="";
- char *dte = (m3p) ? m3p->m3_dte : ap->dte;
- char *ybts= (m3p) ? m3p->m3_ybts : ap->ybts;
- int context = (m3p) ? m3p->m3_context : ap->context;
- char no_ybts = ybts == NULL || !strcmp(ybts, "");
-
- if (m3p && ! dte)
- { dte=nullstring;
- if (context == MAIL_NIFTP) return void_result;
- }
- if (has_relay()) return void_result; /* no relay -> ignore */
-
- if (!no_ybts && (index(ybts, '-') || index(ybts, '+')))
- quote = "\"";
- { char *cont = vlookup(context, vms4_services);
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown",
- dte, context);
- cont = "??";
- }
-
- printf("+%s=%s%s", cont, quote, dte+skip);
- }
- if (!no_ybts) printf(".%s%s", ybts, quote);
- #ifdef notdef
- if (! m3p)
- { int i;
- for (i=0; i< ap->n_relays; i++)
- printf(" AR=\"%s\"", ap->ar[i]);
- }
- #endif notdef
- return void_result;
- }
-
- void_res
- vms4_process(m2p, m3p, m4p)
- Mod2 *m2p;
- Mod3 *m3p;
- Mod4 *m4p;
- { int j;
- int some = 0;
- int slow = 0;
- int noybts = -1;
- int skip = 0; /* Keep gcc -Wall happy */
- char dte[15];
-
- if (strlen(m2p->name) > 32) return 1;
-
- for( j = 0; j < m4p->nquads; j++)
- if (m4p->quads[j].fnumb <= max_fnumb)
- { Atomic *ap;
- if(( ap = getatrec(&(m4p->quads[j]), m2p)) == NULL)
- continue;
- if (has_relay()) continue; /* relay -> ignore */
-
- if (!some++)
- { VOID strcpy(dte, ap->dte);
- skip = strlen(dte);
- }
- while (strncmp(dte, ap->dte, skip))
- skip--, noybts = -1;
- if (!ap->ybts || !*ap->ybts)
- if (noybts>=0) skip--, noybts = -1;
- else noybts = j;
- }
- if (!some) return 1;
-
- printf("D %s\n", vms4_quote(m2p->name));
- printf("A %s", vms4_quote(m2p->name));
- if (slow)
- { printf("\n");
- return 0;
- }
-
- if (skip) printf("+=%.*s", skip, dte);
-
- for(j = 0; j < m4p->nquads; j++)
- if (j != noybts && m4p->quads[j].fnumb <= max_fnumb)
- { Atomic *ap;
- if(( ap = getatrec(&(m4p->quads[j]), m2p)) == NULL)
- continue;
- vms4_single(m2p, ap, m3p, skip);
- }
- if (noybts >= 0) vms4_single(m2p, getatrec(&(m4p->quads[noybts]), m2p),
- m3p, skip);
- printf("\n");
- return 1;
- }
-
- void_res
- vms4m4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- {
- static headed = 0;
-
- if (!m4p || m3p)
- { warn1(1, "VMS4 passed reverse object (%s)",
- (m3p) ? "m3p" : "!m4p");
- return 1;
- }
-
- if( headed == 0 && commentfile)
- { addcomments(stdout, "VMS4 format table", "Lookup Table");
- headed++;
- }
-
- if (shortname) {
- if (!vms4_process(shortname, m3p, m4p)) return 0;
- if(!lexequ(shortname->name, longname->name, strlen(longname->name)))
- if (!vms4_process(longname, m3p, m4p)) return 0;
- }
- else
- if (!vms4_process(longname, m3p, m4p)) return 0;
- return 1;
- }
-
- #ifdef EVER_WANTED
- void_res
- vms4format(longname, shortname, ap, m3p)
- Mod2 *longname, *shortname;
- Atomic *ap;
- Mod3 *m3p;
- {
- char *dte = (m3p) ? m3p->m3_dte : ap->dte;
- char *ybts= (m3p) ? m3p->m3_ybts : ap->ybts;
- int context = (m3p) ? m3p->m3_context : ap->context;
- char no_ybts = ybts == NULL || !strcmp(ybts, "");
-
- if (m3p && ! dte)
- { dte=nullstring; if (context == MAIL_NIFTP) return void_result; }
-
- if (strlen(longname->name) < max_name_len)
- printf("M %s", vms4_quote(longname->name));
- { char *cont = vlookup(context, vms4_services);
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown", dte, context);
- cont = "??";
- }
-
- printf("+%s=%s", cont, dte);
- }
- if (!no_ybts) printf(".%s", ybts);
- if(shortname && !lexequ(shortname->name, longname->name, strlen(longname->name)))
- { printf("M %s", vms4_quote(shortname->name));
- { char *cont = vlookup(context, vms4_services);
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown",
- dte, context);
- cont = "??";
- }
-
- printf("+%s=%s", cont, dte);
- }
- if (!no_ybts) printf(".%s", ybts);
- }
- if (! m3p)
- { int i;
- for (i=0; i< ap->n_relays; i++)
- printf(" AR=\"%s\"", ap->ar[i]);
- }
- printf("\n");
- return void_result;
- }
- #endif EVER_WANTED
- #endif F_VMS4
-
- #ifdef F_VMS5
- /* Thee is no way to represent an applicatio relay, so do not generate it */
- #define has_relay() (! m3p && ap->n_relays && !ignore_relay)
- #define MAXVMS5CONTEXTS (JTMP+1)
- #define MAXVMS5NETWORKS (JANET+1)
-
- int vms5_context_interested[] = { TS29, X29, NIFTP, MAIL_NIFTP, JTMP };
- int vms5_net_interested[] = { JANET, PSS };
-
- static_f char *
- vms5_quote(name)
- char *name;
- { static char buff[1024];
- if (!index(name, '-')) return name;
- VOID sprintf(buff, "\"%s\"", name);
- return buff;
- }
-
- /* ARGSUSED */
- static_f void_res
- vms5_single(m2p, ap, m3p, skip)
- int skip;
- Mod2 *m2p;
- Atomic *ap;
- Mod3 *m3p;
- { char *dte = (m3p) ? m3p->m3_dte : ap->dte;
- char *ybts= (m3p) ? m3p->m3_ybts : ap->ybts;
- int context = (m3p) ? m3p->m3_context : ap->context;
- char no_ybts = ybts == NULL || !strcmp(ybts, "");
- char *cont;
-
- if (m3p && ! dte)
- { dte=nullstring;
- if (context == MAIL_NIFTP) return void_result;
- }
- if (has_relay()) return void_result; /* no relay -> ignore */
-
- cont = vlookup(context, vms5_services);
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown",
- dte, context);
- cont = "??";
- }
- printf("\"%s=%s", cont, dte+skip);
- if (!no_ybts) printf(".%s", ybts);
- printf("\"");
- printf(",");
-
- #ifdef notdef
- if (! m3p)
- { int i;
- for (i=0; i< ap->n_relays; i++)
- printf(" AR=\"%s\"", ap->ar[i]);
- }
- #endif notdef
- return void_result;
- }
-
- static_f void_res
- vms5_process(longname, shortname, m3p, m4p)
- Mod2 *longname;
- Mod2 *shortname;
- Mod3 *m3p;
- Mod4 *m4p;
- { register i, j;
- int nets = 0;
- int where[MAXVMS5CONTEXTS][MAXVMS5NETWORKS];
- int got[MAXVMS5NETWORKS];
- register Table *tp;
-
- /* Initialise the tables .. */
- for (j=0; j<MAXVMS5NETWORKS; j++)
- { got[j] = 0;
- for (i=0; i<MAXVMS5CONTEXTS; i++) where[i][j] = -1;
- }
-
- /* Fill in what we have */
- for(j = 0; j < m4p->nquads; j++)
- if (m4p->quads[j].fnumb <= max_fnumb &&
- (tp = gettab(m4p->quads[j].fnumb)) &&
- tp->T_context < MAXVMS5CONTEXTS &&
- tp->T_network < MAXVMS5NETWORKS)
- where[tp->T_context][tp->T_network] = j;
-
- for (i=0; i < sizeof vms5_net_interested / sizeof vms5_net_interested[0]; i++)
- { int net = vms5_net_interested[i];
- for(j = 0;
- j < sizeof vms5_context_interested / sizeof vms5_context_interested[0];
- j++)
- if(where[vms5_context_interested[j]][net] >= 0) got[net]++;
- }
-
- /* Count the number of nets */
- for (j=0; j<MAXVMS5NETWORKS; j++) if (got[j]) nets++;
-
- printf("D S %s\n", vms5_quote(longname->name));
- if(shortname && !lexequ(shortname->name, longname->name, strlen(longname->name)))
- printf("D A %s\n", vms5_quote(shortname->name));
-
- /* Print info for nets that have some info */
- for (i=0; i < (sizeof vms5_net_interested / sizeof vms5_net_interested[0]); i++)
- if (got[vms5_net_interested[i]])
- { int net = vms5_net_interested[i];
- char *netname = vlookup(net, netnames);
- int skip = 0; /* Keep gcc -Wall happy */
- char dte[15];
- int some = 0;
-
- for(j = 0;
- j < (sizeof vms5_context_interested / sizeof vms5_context_interested[0])-1;
- j++)
- if (m4p->quads[where[vms5_context_interested[j]][net]].fnumb <= max_fnumb)
- { Atomic *ap;
- if(( ap = getatrec(&(m4p->quads[where[vms5_context_interested[j]][net]]), longname)) == NULL)
- continue;
- if (has_relay()) continue; /* relay -> ignore */
-
- if (!some++)
- { VOID strcpy(dte, ap->dte);
- skip = strlen(dte);
- }
- while (strncmp(dte, ap->dte, skip)) skip--;
- }
- if (!some) continue;
-
- printf("A S %s %s ", vms5_quote(longname->name), netname);
- fflush(stdout);
- if(shortname && !lexequ(shortname->name, longname->name, strlen(longname->name)))
- printf("/ALIAS=(\"%s\")", shortname->name);
- printf("/FAST_SELECT ");
- printf("\"%.*s\" ", skip, dte);
- fflush(stdout);
-
- /* Now the quads themselves */
- for(j = 0;
- j < (sizeof vms5_context_interested / sizeof vms5_context_interested[0])-1;
- j++)
- { Atomic *ap;
-
- vprintf2(2, "[try %d -> %d]\n", j, where[vms5_context_interested[j]][net]);
- if(!(ap=getatrec(&(m4p->quads[
- where[vms5_context_interested[j]][net]
- ]), shortname)))
- continue;
- vprintf2(2, "[%d -> %x]\n", j, ap);
- vms5_single(shortname, ap, m3p, skip);
- }
- printf("\n");
- }
- return 1;
- }
-
- void_res
- vms5m4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- {
- static headed = 0;
-
- if (!m4p || m3p)
- { warn1(1, "VMS5 passed reverse object (%s)",
- (m3p) ? "m3p" : "!m4p");
- return 1;
- }
-
- if( headed == 0 && commentfile)
- { addcomments(stdout, "VMS5 format table", "Lookup Table");
- headed++;
- }
-
- if (!vms5_process(longname, shortname, m3p, m4p)) return 0;
- return 1;
- }
-
- #endif F_VMS5
-
- #ifdef F_SMAIL
- void_res
- smailformat(longname, shortname, ap, m3p)
- Mod2 *longname, *shortname;
- Atomic *ap;
- Mod3 *m3p;
- {
- if (!m3p) {
- printf("%s ", longname->name);
- switch(ap->network) {
- case PSS:
- printf("pss,");
- break;
-
- case JANET:
- printf("janet,");
- break;
- }
-
- if (ap->dte && *ap->dte) printf("%s", ap->dte);
- if (ap->ybts && *ap->ybts)
- printf("/%s", ap->ybts);
- { int i;
- for (i=0; i< ap->n_relays; i++)
- printf("%s%s", i==0?",":"%", ap->ar[i]);
- }
- printf("\n");
- if (shortname && !lexequ(shortname->name, longname->name, strlen(longname->name))) {
- printf("%s ", shortname->name);
- switch(ap->network) {
- case PSS:
- printf("pss,");
- if (pssgateway)
- printf("%s", pssgateway);
- break;
-
- case JANET:
- printf("janet,");
- if (janetgateway)
- printf("%s", janetgateway);
- break;
- }
-
- if (ap->dte && *ap->dte) printf("%s", ap->dte);
- if (ap->ybts && *ap->ybts)
- printf("/%s", ap->ybts);
- { int i;
- for (i=0; i< ap->n_relays; i++)
- printf("%s%s", i==0?",":"%", ap->ar[i]);
- }
- printf("\n");
- }
- }
- else {
- printf("%s %s\n", m3p->m3_string, longname->name);
- }
- return void_result;
- }
- #endif F_SMAIL
-
- #ifdef F_SENDMAIL
- /* Generate uk.dom, abbrev.dom */
-
- /* ARGSUSED */
- void_res
- sendmailformat(longname, shortname, ap, m3p) /* sendmail domain table format */
- Mod2 *longname;
- Mod2 *shortname;
- Atomic *ap;
- Mod3 *m3p;
- {
- File_list *filep;
- FILE *fp;
- char *name1, *name2, *dmn1, *dmn2;
- int strip_len1=0, strip_len2=0;
- char end_name1[100], end_name2[100];
- char *dot;
- static char lastname[1024] = { '\0' };
- static char lastabbrev[1024] = { '\0' };
- static char lastrname[1024] = { '\0' };
- static char lastrelay[1024] = { '\0' };
- char *flip();
-
- if (!ap)
- { warn0(1, "SENDMAIL passed reverse object");
- return void_result;
- }
-
- if (! shortname) shortname = longname;
-
- if( longshort == LONG ) /* output in short = alias of long */
- name1 = longname->name, name2 = shortname->name;
- else name1 = shortname->name, name2 = longname->name;
-
- if (!lexequ(name1, name2, strlen(name1)) && strcmp(lastabbrev, name2))
- { File_list *filep;
- if((filep = findfile(fil_list, "-abbrev.dom-...", 1)) == NULL)
- { static int warned = 0;
- if (warned == 0)
- { warn0(1, "can't find a place for abbreviations");
- warned++;
- }
- }
- else
- { fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- { addcomments(fp, filep->fname, "Abbreviation Table");
- filep->flags |= USED;
- }
- fprintf(fp, "%-20s", flip(name2));
- fprintf(fp, " %s\n", flip(name1));
- }
- strcpy(lastabbrev, name2);
- }
-
- filep = findfile(fil_list, name1, longshort != LONG);
-
- /* relays and not a local domain */
- if(ap->n_relays > 0 && ! (filep && (filep->flags & LOCAL)) &&
- (strcmp(lastrname, name1) || strcmp(lastrelay, ap->ar[0]) ||
- ap->n_relays > 1))
- { File_list *filep;
- if((filep = findnet(fil_list, ap->network)) == NULL)
- { static int warned = 0;
- if (warned++ == 0)
- warn0(1, "can't find a place for channel info");
- }
- else
- { int i;
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- { addcomments(fp, filep->fname, "Channel Table");
- filep->flags |= USED;
- }
- fprintf(fp, "%-20s", noflip(name1));
- for( i = 0; i < ap->n_relays; i++) /* dump the AR */
- fprintf(fp, " %s",
- noflip(longshort_name(ap->ar[i])));
- fprintf(fp, "\n");
-
- /* Other style name ? */
- if( (strlen(name1) != strlen(name2)) ||
- ! lexequ(name1, name2, strlen(name1)))
- { fprintf(fp,"%-20s", noflip(name2));
- for( i = 0; i < ap->n_relays; i++)
- fprintf(fp, " %s",
- noflip(longshort_name(ap->ar[i])));
- fprintf(fp, "\n");
-
- }
- }
- strcpy(lastrname, name1);
- strcpy(lastrelay, ap->ar[0]);
- }
-
- if(filep == NULL)
- { warn1(1, "can't find a place for %s", name1);
- return void_result;
- }
-
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- { addcomments(fp, filep->fname, "Domain Table");
- filep->flags |= USED;
- }
-
- if( longshort == LONG ) /* output in short = alias of long */
- { dmn1 = filep->ldname; dmn2 = filep->dname; }
- else { dmn1 = filep->dname; dmn2 = filep->ldname; }
-
- strcpy(end_name1, name1 +strlen(dmn1)); /* name within domain */
-
-
- if (dot = index(end_name1, '.'))
- { strip_len1 = strlen(dot); *dot = '\0'; } /* single level of */
-
- /* cheapo check for a repeat of the last domain */
- if (strcmp(end_name1, lastname) == 0) return void_result;
-
- VOID strcpy(lastname, end_name1);
-
- fprintf(fp, "%-20s", flip(end_name1));
- fprintf(fp, " %s", flip(name1) + strip_len1);
- putc('\n', fp);
-
- if((filep = findfile(fil_list, name2, longshort == LONG)) == NULL)
- { warn1(1, "can't find a place for %s", name1);
- return void_result;
- }
-
- strcpy(end_name2, name2 +strlen(dmn2)); /* other one */
- if (dot = index(end_name2, '.')) /* domain only ... */
- { strip_len2 = strlen(dot); *dot = '\0'; }
-
- /* Other style name ? */
- if( (strlen(end_name1) != strlen(end_name2)) ||
- ! lexequ(end_name1, end_name2, strlen(end_name1)))
- {
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- {
- addcomments(fp, filep->fname, "Domain Table");
- filep->flags |= USED;
- }
- fprintf(fp,"%-20s", flip(end_name2));
- fprintf(fp, " %s\n", flip(name2) + strip_len2);
- }
- return void_result;
- }
-
- void_res
-
- sendmaildomain(dp)
- Domain *dp;
- { static char name1[] = "-top.dom-...";
- File_list *filep;
- FILE *fp;
- char *flip();
-
- if((filep = findfile(fil_list, name1, 1)) == NULL)
- { warn1(1, "can't find a place for %s", name1);
- return void_result;
- }
-
- fp = getfp(filep->fname, "w");
- if( (filep->flags & USED) == 0 && commentfile)
- {
- addcomments(fp, filep->fname, "Top Domain Table");
- filep->flags |= USED;
- }
-
- fprintf(fp, "%-20s", flip(dp->name));
- fprintf(fp, " %s\n", flip(longshort_name(dp->gateway)));
-
- return void_result;
- }
- #endif F_SENDMAIL
-
- # ifdef F_YORK21
- static_f void_res
- york_21format(m2p, ap, m3p) /* york D2.1 directory format */
- Mod2 *m2p;
- Atomic *ap;
- Mod3 *m3p;
- { char *name = m2p->name;
- /* This is the DTE to use:
- * EITHER ap->dte for forward
- * OR part of text for reverse
- */
- char *dte = (m3p) ? m3p->m3_dte : ap->dte;
- char *ybts= (m3p) ? m3p->m3_ybts : ap->ybts;
- int context = (m3p) ? m3p->m3_context : ap->context;
- int network = (m3p) ? m3p->m3_network : ap->network;
- char no_ybts = ybts == NULL || !strcmp(ybts, "");
-
- if (m3p && ! dte)
- { dte=nullstring; if (context == MAIL_NIFTP) return void_result; }
-
- { char * net = vlookup(network, netnames);
- char *cont = vlookup(context, exp_21services);
-
- if (!net)
- { warn2(1, "%10s: net 0x%02x unknown",
- name, network);
- net = "??";
- }
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown",
- name, context);
- cont = "??";
- }
- printf("0:%s:%s:", net, cont, name);
- }
- /* <isunix>:<network>:<service>:<name>:<addr>:<comment> */
- if(stripoff && lexequ(stripoff, name, strlen(stripoff)) )
- printf("%s:", name + strlen(stripoff));
- else
- printf("%s:", name);
-
- /* Prefix with gateway if needed .... */
- if(network == PSS && pssgateway ) printf("%s", pssgateway);
- if(network == JANET && janetgateway) printf("%s", janetgateway);
-
- /* The DTE .... */
- printf("%s", dte);
- if (!no_ybts) printf("/%s", ybts);
- printf(":");
-
- /* The comment */
- printf("\n");
-
- if (ap && ap->dte && dte != ap->dte && strcmp(dte, ap->dte))
- warn3(1, "%-18s DTE is %-14s rather than %-14s",
- name, dte, ap->dte);
- return void_result;
- }
-
- static_f void_res
- york_21single(m2p, m3p, m4p)
- Mod2 *m2p;
- Mod3 *m3p;
- Mod4 *m4p;
- { int j;
- int x29 = -1; /* the quad which contains the x29 service if any */
- Atomic *ap;
- char dte[15];
-
- VOID strcpy(dte, "<no x29 service>"); /* will not match */
-
- /* Let's see if we can find an X29 service.
- * If so, output it first & remember the DTE.
- * Then we may be able to omit later duplicates ....
- *
- * Also: If no X29, but there IS a TS29, THEN ....
- * you could be clever & generate T entry (-> F & M)
- * Any volunteers ?? (pb@cl.cam.ac.uk)
- */
- if (!m3p && cont_want[X29]) for( j = 0; j < m4p->nquads; j++)
- if (m4p->quads[j].fnumb <= max_fnumb)
- { Table *tp = gettab(m4p->quads[j].fnumb);
- if (!tp || tp->T_context != X29) continue;
- if(( ap = getatrec(&(m4p->quads[j]), m2p)) == NULL)
- continue;
-
- VOID strcpy(dte, ap->dte);
- york_21format(m2p, ap, m3p);
- x29 = j;
- break;
- }
-
- for( j = 0; j < m4p->nquads; j++) if (m4p->quads[j].fnumb <= max_fnumb)
- { int process_this_one = 0;
-
- if (j == x29) continue; /* Already done x29 */
-
- if(( ap = getatrec(&(m4p->quads[j]), m2p)) == NULL)
- continue;
- if(m3p && (ap-> context != m3p->m3_context ||
- ap->network != m3p->m3_network))
- continue;
- if (strcmp(dte, ap->dte)) process_this_one++;
- else
- { char *expected_ybts=vlookup(ap->context,def_ybstring);
- char *given_ybts = ap->ybts;
-
- if (!expected_ybts) expected_ybts = "";
- if (!given_ybts) given_ybts = "";
- if (strcmp(given_ybts, expected_ybts))
- process_this_one++;
- }
- if (process_this_one)
- york_21format(m2p, ap, m3p);
- }
- return 1;
- }
-
- void_res
- york21m4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- {
- static headed = 0;
-
- if( headed == 0 && commentfile)
- {
- addcomments(stdout, (m3p) ?
- "york 2.1 format reverse NRS table" :
- "york 2.1 format NRS table",
- "Lookup Table");
- headed++;
- }
-
- if (!m4p || m3p) return 0;
-
- if (shortname) {
- if (!york_21single(shortname, m3p, m4p)) return 0;
- if(!lexequ(shortname->name, longname->name, strlen(longname->name)))
- if (!york_21single(longname, m3p, m4p)) return 0;
- }
- else if (!york_21single(longname, m3p, m4p)) return 0;
- return 1;
- }
-
- # endif F_YORK21
-
- # ifdef F_DBM1
- /* ARGSUSED */
- void_res
- dbm1_single(n_quad, m4p)
- int n_quad;
- Mod4 *m4p;
- { FILE *fp;
- int i;
- FILE *locaterec();
- Quad *qp;
-
- if (n_quad >= 0 && (fp=locaterec(qp = &(m4p->quads[n_quad]))))
- {
- for( i = 1; i <= qp->nlines; i++)
- { int len;
- char string[MAXNAMELEN];
- char tag[TAGSIZE];
-
- getstr(fp, tag, 0, 4); /* the tag field */
- for (len=4; tag[len-1] == ' '; len--);
- tag[len] = '\0';
- len = getint(fp, 5); /* length of next field */
- getstr(fp, string, 0, len);
- printf("%s%s %s", (i>1) ? "\r" : "", tag, string);
- }
- }
- printf("%c", DBSEP);
- return void_result;
- }
-
- #define NEWS DESC+1
- #define MAXDBM1CONTEXTS DESC+2
- #define MAXNETWORKS (JANET+1)
-
- int context_interested[] = { TS29, X29, NIFTP, MAIL_NIFTP, JTMP, NEWS, DESC };
- int net_interested[] = { JANET, PSS };
-
- void_res
- dbm1m4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- { register i, j;
- int nets = 0;
- Mod2 *mainname;
- Mod2 *othername;
- int where[MAXDBM1CONTEXTS][MAXNETWORKS];
- int got[MAXNETWORKS];
- register Table *tp;
- static long t_time = 0;
- static count = 0;
-
- if (m3p || !m4p) return 0;
-
- if (t_time == 0) time(&t_time);
-
- /* Initialise the tables .. */
- for (j=0; j<MAXNETWORKS; j++)
- { got[j] = 0;
- for (i=0; i<MAXDBM1CONTEXTS; i++) where[i][j] = -1;
- }
-
- /* Fill in what we have */
- for(j = 0; j < m4p->nquads; j++)
- if (m4p->quads[j].fnumb <= max_fnumb &&
- (tp = gettab(m4p->quads[j].fnumb)) &&
- tp->T_context < MAXDBM1CONTEXTS &&
- tp->T_network < MAXNETWORKS)
- where[tp->T_context][tp->T_network] = j;
-
- for (i=0; i < sizeof net_interested / sizeof net_interested[0]; i++)
- { int net = net_interested[i];
- for(j = 0;
- j < sizeof context_interested / sizeof context_interested[0];
- j++)
- if(where[context_interested[j]][net] >= 0) got[net]++;
- }
-
- /* Count the number of nets */
- for (j=0; j<MAXNETWORKS; j++) if (got[j]) nets++;
-
- if (!shortname) shortname=longname;
-
- if (longshort == LONG) mainname = longname , othername = shortname;
- else mainname = shortname, othername = longname;
-
- printf("%c##%d %s\n", R_ALIAS, count, mainname->name);
- if (strcmp(mainname->name, othername->name))
- printf("%c%s %s\n", R_ALIAS, mainname->name, othername->name);
- printf("%c%s %s %d %d %d %d %d %d",
- R_MAIN, othername->name, mainname->name,
- t_time, count++, DEF_LOCAL, DEF_OLD, DEF_DISABLED,
- nets);
-
- /* Print info for nets that have some info */
- for (i=0; i < (sizeof net_interested / sizeof net_interested[0]); i++)
- if (got[net_interested[i]])
- { int net = net_interested[i];
- char *netname = vlookup(net, lc_netnames);
-
- #define printgw(m4p, off) printf(" %d", (off<0) ? 0 : m4p->quads[off].ngtwys)
- /* Net name and some gateways */
- printf(" %d", DEF_MAXFTP);
- printgw(m4p, where[NIFTP][net]);
- printgw(m4p, where[MAIL_NIFTP][net]);
- printgw(m4p, where[JTMP][net]);
- printf(" %d", 0); /* newsgates */
- printf(" %s%c", netname, DBSEP);
-
- /* Now the quads themselves */
- for(j = 0;
- j < (sizeof context_interested / sizeof context_interested[0])-1;
- j++)
- dbm1_single(where[context_interested[j]][net], m4p);
- }
- dbm1_single(where[DESC][JANET], m4p);
- printf("\n");
- return 1;
- }
-
- /* ARGSUSED */
- void_res
- dbm1format(longname, shortname, ap, m3p)
- Mod2 *longname, *shortname;
- Atomic *ap;
- Mod3 *m3p;
- { Mod2 *mainname = shortname;
-
-
- if (!m3p)
- { warn0(1, "DBM1 single passed forward object");
- return void_result;
- }
-
- if (!mainname || longshort == LONG) mainname = longname;
-
- if (mixlow != MIXED) VOID lowerfy(m3p->m3_string); /* true .. */
- printf("%c%c %s %s\n", R_REV, m3p->m3_context + '0',
- mainname->name, m3p->m3_string); /* UGH !! */
-
- return void_result;
- }
-
- void_res
- dbm1domain(dp)
- Domain *dp;
- {
- printf("%c%s %s\n", R_DOMAIN, dp->name, dp->gateway); /* UGH !! */
-
- return void_result;
- }
- # endif F_DBM1
-
- #ifdef F_PRIME
- void_res
- primeformat(longname, shortname, ap, m3p)
- Mod2 *longname, *shortname;
- Atomic *ap;
- Mod3 *m3p;
- {
- int i;
-
- if (m3p) printf("Calling_Address: %s\n", m3p -> m3_string);
-
- printf("Standard_Name: %s\n", longname -> name);
-
- printf("Abbreviated_Name: %s\n",
- (shortname) ? shortname -> name : longname -> name);
-
- if (m3p)
- { if (m3p->m3_dte) printf("DTE_String: %s\n", m3p->m3_dte);
- if (*(m3p->m3_ybts)) printf("YBTS_String: %s\n",m3p->m3_ybts);
- if (ap) for (i = 0; i < ap->n_descs; i++)
- printf("Description: %s\n", ap->desc[i]);
- }
- else
- { if (ap->dte && *ap->dte)
- printf("DTE_String: %s\n", ap->dte);
- if (ap->ybts && *ap->ybts)
- printf("YBTS_String: %s\n", ap->ybts);
-
- for (i = 0; i < ap->n_relays; i++)
- printf("Application_Relay: %s\n", ap->ar[i]);
- for (i = 0; i < ap->n_descs; i++)
- printf("Description: %s\n", ap->desc[i]);
- }
-
- printf("\n");
-
- return void_result;
- }
-
- void_res
- primedomain(dp)
- Domain *dp;
- {
- printf("domain: %s",dp->name);
- printf(" -gate %s\n",dp->gateway);
- return void_result;
- }
-
- #endif F_PRIME
-
- # ifdef F_EDTEXT
- /*
- * Go through all the quads associated with this name (s). This will
- * lead us to all the forward, reverse, and description info (I hope!).
- * call edtextformat() with appropriate args to make it do the Right Thing.
- */
- void_res
- edtextm4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- {
- int i, j;
- Atomic *ap, fakeap;
- Mod3 *mm3p;
- Table *tp;
- static headed = 0;
- static partial = 0;
- char *prefix1 = (options & O_ED_SHORT) ?
- (shortname) ? shortname->name : longname->name :
- (char *) 0;
- char *prefix2 = (options & O_ED_LONG) ? longname->name :
- (char *) 0;
-
- if (!m4p || m3p)
- { warn1(1, "EDTEXT passed reverse object (%s)",
- (m3p) ? "m3p" : "!m4p");
- return 1;
- }
-
- if( headed == 0 && commentfile)
- { char * type;
- switch (options & O_ED_MASK)
- {
- case O_ED_SIMPLE: type = "simple format"; break;
- case O_ED_SHORT: type = "short format"; break;
- case O_ED_LONG: type = "long format"; break;
- case O_ED_LONG|O_ED_SHORT: type = "long & short format";break;
- default: type = "unknown format"; break;
- }
- addcomments(stdout, "Edinburgh text format NRS table", type);
- headed++;
- }
-
-
- /* print out the name(s) if needed*/
- if (!(prefix1 && prefix2))
- {
- if (!prefix2)
- { if (prefix1) printf("%-*s ", FL_PREF1, prefix1);
- printf("%-*s %s\n", FL_CNTX, "SN", longname->name);
- }
- if (shortname && !prefix1)
- { if (prefix2) printf("%-*s ", FL_PREF2, prefix2);
- printf("%-*s %s\n", FL_CNTX, "AN", shortname->name);
- }
- }
-
- /* print out the DESC info at the top ... */
- for( j = 0; j < m4p->nquads; j++)
- if (m4p->quads[j].fnumb==trip2fnumb[DESC][JANET][DIR_FORWARDS] &&
- (ap = getatrec(&(m4p->quads[j]),
- (shortname) ? shortname : longname)))
- edtextformat(longname, ap, NULL, prefix1, prefix2);
-
- /* ... then print out the rest */
- for( j = 0; j < m4p->nquads; j++)
- {
- if ((m4p->quads[j]).fnumb ==
- trip2fnumb[DESC][JANET][DIR_FORWARDS]) continue;
-
- /* forward lookup? */
- if ((m4p->quads[j]).fnumb <= max_fnumb &&
- (ap = getatrec(&(m4p->quads[j]),
- (shortname) ? shortname : longname)))
- mm3p = NULL;
- else if ((m4p->quads[j]).fnumb > fnumb)
- /* reverse lookup. groan - magic numbers */
- { if (partial && !gettab((m4p->quads[j]).fnumb - max_fnumb))
- continue;
- if (!(mm3p = getm3rec((m4p->quads[j]).disp)))
- { warn3(0,
- "getm3rec problem on %s line %d of %d",
- longname->name, m4p->quads[j].disp,
- m4p->quads[j].fnumb);
- continue;
- }
- ap = (Atomic *) 0; /* Keep gcc -Wall happy */
- }
- else if ((i = (m4p->quads[j]).fnumb) ==
- trip2fnumb[JTMP_FILES][JANET][DIR_FORWARDS] ||
- i == trip2fnumb[JTMP_REG ][JANET][DIR_FORWARDS])
- /*
- * These contexts do not appear to have any
- * attached info. So we fake up a record to hand
- * to edtextformat().
- * There are the ones I came across; there are probably
- * others that will need the same treatment if they ever
- * do appear in the nrs.
- * It would help if I understood what these contexts
- * meant! What is YBTS-NODE?? MAIL-X29?? My aching brain...
- */
- { tp = gettab((m4p->quads[j]).fnumb);
- bzero(&fakeap, sizeof fakeap);
- if (!tp)
- { if (!partial)
- { Quad *x = &(m4p->quads[j]);
- warn1(0,
- "context not included in .cf file for %s",
- longname->name);
- warn3(0,
- "Context %d, subnetwork %d, direction %d",
- fnumb2trip[x->fnumb].f_cont,
- fnumb2trip[x->fnumb].f_subn,
- fnumb2trip[x->fnumb].f_dirn);
- warn3(0, "[ fnumb=%d, disp=%d, nlines=%d ]\n",
- x->fnumb, x->disp, x->nlines);
- partial++;
- }
- continue;
- }
- fakeap.context = tp->T_context;
- fakeap.network = tp->T_network;
- ap = &fakeap;
- mm3p = NULL;
- }
- else
- /*
- * HELP!!!
- * If it ever gets here then I don't understand what is
- * going on. But I will at least let the user know...
- */
- { tp = gettab((m4p->quads[j]).fnumb);
- if (!partial || tp)
- { Quad *x = &(m4p->quads[j]);
- if (!tp) warn3(0,
- "context %s in %s not included in .cf file for %s",
- vlookup(fnumb2trip[x->fnumb].f_cont, contexts),
- vlookup(fnumb2trip[x->fnumb].f_subn, netnames),
- longname->name);
- warn3(0,
- "Context %d, subnetwork %d, direction %d",
- fnumb2trip[x->fnumb].f_cont,
- fnumb2trip[x->fnumb].f_subn,
- fnumb2trip[x->fnumb].f_dirn);
- warn3(0, "[ fnumb=%d, disp=%d, nlines=%d ]\n",
- x->fnumb, x->disp, x->nlines);
- if (!tp)partial++;
- }
- continue;
- }
- edtextformat(longname, ap, mm3p, prefix1, prefix2);
- }
-
- printf("\n");
- return(1); /* OK -- we did it ! */
- }
-
-
-
- /*
- * print the stuff out. If m3p is non null we are printing out a
- * reverse entry. I am sure this could be cleaner.
- */
- void_res
- edtextformat(m2p, ap, m3p, prefix1, prefix2)
- Mod2 *m2p;
- Atomic *ap;
- Mod3 *m3p;
- char *prefix1;
- char *prefix2;
- { int context = (m3p) ? m3p->m3_context : ap->context;
- int network = (m3p) ? m3p->m3_network : ap->network;
- char *cont = vlookup(context, contexts);
- char *net = vlookup(network, netabbrevs);
- char *name = m2p->name;
- if (!cont)
- { warn2(1, "%10s: context 0x%02x unknown", name, context);
- cont = "??";
- }
- if (!net)
- { warn2(1, "%10s: net 0x%02x unknown", name, network);
- net = "??";
- }
-
- if (context == DESC)
- { /* If m3p then we already done it */
- if (prefix1) printf("%-*s ", FL_PREF1, prefix1);
- if (prefix2) printf("%-*s ", FL_PREF2, prefix2);
- if( !m3p && ap->n_descs > 0 )
- { int desc;
- printf("%-*s ", FL_CNTX, "DI");
- for (desc=0; desc < ap->n_descs; desc++)
- printf("%s%s", (desc==0) ? "" : " ", ap->desc[desc]);
- }
- printf("\n");
- return(0);
- }
-
- /*
- * you can tell this is a hack by the number of times
- * I go `if (m3p)'...
- */
- /*
- * Special cases... perhaps more contexts belong here too.
- */
- if (prefix1) printf("%-*s ", FL_PREF1, prefix1);
- if (prefix2) printf("%-*s ", FL_PREF2, prefix2);
-
- if (m3p) /* Reverse entry */
- printf("%-*s %-*s R CA %s",
- FL_CNTX, cont, FL_NET, net, m3p->m3_string);
- else /* forward entry... DI caught above */
- { char *dte = ap->dte;
- char *ybts = ap->ybts;
- char no_ybts = ybts == NULL || !strcmp(ybts, "");
-
- if (! dte) dte = "";
-
- if (context == JTMP_FILES || context == JTMP_REG)
- printf("%-*s %-*s", FL_CNTX, cont, FL_NET, net);
- else
- printf("%-*s %-*s F DT %s", FL_CNTX, cont, FL_NET, net, dte);
- if( ! no_ybts )
- printf(" YB %s", ybts);
-
- if( ap->n_relays > 0 )
- { int relay;
- printf(" AR ");
- for (relay=0; relay < ap->n_relays; relay++)
- printf("%s%s", (relay) ? "; " : "",
- ap->ar[relay]);
- }
- }
-
- printf("\n");
-
- return(0);
- }
-
- void_res
- edtextdomain(dp)
- Domain *dp;
- { printf("%-*s %-*s %s\n", FL_CNTX, "DM", FL_DOM, dp->name, dp->gateway);
- return void_result;
- }
- # endif F_EDTEXT
-
- # ifdef F_VME
- char *
- vmehash(data)
- char *data;
- { int val;
- static char res[3];
- static char table[] =
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
- for (val=0; *data; data++) val = val + *data;
-
- res[0] = table[val % (sizeof table -1)];
- res[1] = table[(val / (sizeof table -1)) % (sizeof table -1)];
-
- res[sizeof res -1] = '\0';
- return res;
- }
-
- static_f void
- vmecompress(to, from)
- char *from, *to;
- {
- register char * p;
- if (!strncmp(from, VME_STRIP, sizeof(VME_STRIP) -1))
- from += sizeof(VME_STRIP) -1;
-
- for(p=to; *from; from++) if (*from != '.') *to++ = *from;
- *to = '\0';
- }
-
- static_f void
- vmeout(lftf, nrsa, nrsb, roucn)
- char *lftf, *nrsa, *nrsb, *roucn;
- { printf("%-*.*s", VME_HFTFLEN, VME_HFTFLEN, vmehash(lftf));
- printf("%-*.*s", VME_HNRSALEN, VME_HNRSALEN, vmehash(nrsa));
- printf("%-*.*s", VME_HNRSBLEN, VME_HNRSBLEN, (nrsb)?vmehash(nrsb):"");
- printf("%-*d", VME_SERCNLEN, VME_SERCN_RELAY);
- printf("%-*d", VME_PROPCNLEN, VME_PROPCN_ROUTE);
- printf("%-*s", VME_MAILSRLEN, "");
- printf("%-*s", VME_LFTFLEN, lftf);
- printf("%-*s", VME_NRSALEN, nrsa);
- printf("%-*s", VME_NRSBLEN, (nrsb) ? nrsb : "");
- printf("%-*.*s", VME_ROUCNLEN, VME_ROUCNLEN, roucn);
- printf("\n");
- }
-
- /* ARGSUSED */
- void_res
- vmeformat(longform, shortform, ap, m3p) /* vme domain table format */
- Mod2 *longform;
- Mod2 *shortform;
- Atomic *ap;
- Mod3 *m3p;
- { char compressed[VME_LFTFLEN+1];
- static headed = 0;
-
- if (!ap)
- { warn0(1, "VME passed reverse object");
- return void_result;
- }
-
- if (!shortform)
- { warn1(1, "VME passed %s without shortform", longform->name);
- return void_result;
- }
-
- if( headed == 0 && commentfile)
- { addcomments(stdout, "VME format NRS", "Mail table");
- headed++;
- }
-
- vmecompress(compressed, shortform->name);
- vmeout(compressed, shortform->name, longform->name, "NOTICF");
-
- return void_result;
- }
-
- int
- vmem4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- {
- int j;
- Atomic *ap;
-
- if (!m4p || m3p)
- { warn1(1, "VME passed reverse object (%s)",
- (m3p) ? "m3p" : "!m3p");
- return 1;
- }
-
- for( j = 0; j < m4p->nquads; j++)
- if ((m4p->quads[j]).fnumb <= max_fnumb &&
- (ap = getatrec(&(m4p->quads[j]),
- (shortname) ? shortname : longname)))
- { vmeformat(longname, shortname, ap, NULL);
- /* If JANET and PSS, only output one of them */
- break;
- }
-
- return(1); /* OK -- we did it ! */
- }
-
- void_res
- vmedomain(dp)
- Domain *dp;
- { char compressed[VME_LFTFLEN+1];
- char compress2[VME_LFTFLEN+1];
-
- vmecompress(compressed, dp->name);
- vmecompress(compress2, dp->gateway);
- vmeout(dp->name, compressed, 0, compress2);
-
- return void_result;
- }
- # endif F_VME
-
- # ifdef F_PP
- static_f void
- pp_domain(hostname, stdname, file)
- Mod2 *hostname, *stdname;
- FILE *file;
- { fprintf(file, "%s:", flip(hostname->name));
- fprintf(file, "%s\n", flip(stdname->name));
- }
-
- static_f int
- pp_channel(hostname, m4p, file)
- Mod2 *hostname;
- Mod4 *m4p;
- FILE *file;
- { Atomic *ap;
- int j;
- char buff[4096];
- char *ptrs[10];
- int done_janet = 0;
- int done_pss = 0;
- int done = 0;
- int i;
-
- ptrs[0] = buff;
-
- for( j = 0; j < m4p->nquads; j++)
- {
- if ((m4p->quads[j]).fnumb ==
- trip2fnumb[MAIL_NIFTP][JANET][DIR_FORWARDS])
- { if (done_janet++) continue;
- }
- else if ((m4p->quads[j]).fnumb ==
- trip2fnumb[MAIL_NIFTP][PSS][DIR_FORWARDS])
- { if (done_pss++) continue;
- }
- else continue;
-
- /* forward lookup? */
- if (ap = getatrec(&(m4p->quads[j]), hostname))
- { if (ap->n_relays)
- sprintf(ptrs[done], "%s()",
- flip(longshort_name(ap->ar[0])));
- else switch(ap->network) {
- case PSS:
- sprintf(ptrs[done],
- "%s(gb-%s)", flip(hostname->name),
- lexequ(ap->dte, "2342", 4) ? "pss" :
- "ipss");
- break;
-
- case JANET:
- sprintf(ptrs[done], "%s(gb-janet)",
- flip(hostname->name));
- break;
- }
- for (i=0; i<done; i++)
- if (!strcmp(ptrs[i], ptrs[done])) break;
- if (i < done) continue;
- ptrs[done+1] = ptrs[done] + strlen(ptrs[done]) + 1;
- done++;
- }
- }
-
- if (!done) return 0;
-
- fprintf(file, "%s:", flip(hostname->name));
- for (i=0; i<done; i++) fprintf(file, "%s%s", (i==0) ? "":",", ptrs[i]);
- fprintf(file, "\n");
- return 1;
- }
-
- static FILE *dmnfile = (FILE *) 0;
- static FILE *chanfile = (FILE *) 0;
-
- void_res
- ppm4rec(m4p, shortname, longname, m3p)
- Mod4 *m4p;
- Mod3 *m3p;
- Mod2 *shortname;
- Mod2 *longname;
- { Mod2 *stdform, *aliasform;
- static int first = 1;
-
- if (m3p)
- { warn0(1, "PP passed reverse object");
- return 1;
- }
-
- if (first)
- { File_list *filep;
-
- if(filep = findfile(fil_list, "-chan-...", 1))
- chanfile = getfp(filep->fname, "w");
- if (!chanfile) chanfile = stdout;
- if(commentfile) addcomments(chanfile, (m3p) ?
- "PP format reverse NRS table" :
- "PP format NRS table",
- "Lookup Table");
-
- if(filep = findfile(fil_list, "-dmn-...", 1))
- dmnfile = getfp(filep->fname, "w");
- if (!dmnfile) fprintf(stderr, "No dmn file\n");
- else if(commentfile) addcomments(dmnfile, (m3p) ?
- "PP format reverse NRS table" :
- "PP format NRS table",
- "Lookup Table");
- first = 0;
- }
-
- if (!shortname) shortname = longname;
-
- if( longshort == LONG ) /* output in short = alias of long */
- stdform = longname, aliasform = shortname;
- else stdform = shortname, aliasform = longname;
-
- if (!pp_channel(stdform, m4p, chanfile)) return 1;
-
- if (dmnfile)
- { pp_domain(stdform, stdform, dmnfile);
- if (aliasform &&
- !lexequ(aliasform->name, stdform->name, strlen(longname->name)))
- pp_domain(aliasform, stdform, dmnfile);
- }
- return 1;
- }
-
- void_res
- ppdomain(dp)
- Domain *dp;
- {
- FILE *fp;
-
- if (chanfile)
- { fprintf(chanfile, "%s:", flip(dp->name));
- fprintf(chanfile, "%s()\n", flip(longshort_name(dp->gateway)));
- }
- if (dmnfile)
- { fprintf(dmnfile, "%s:", flip(dp->name));
- fprintf(dmnfile, "%s *\n", flip(dp->name));
- }
- return void_result;
- }
- # endif F_PP
-